package com.huizluo.module3.fightmaster;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class CardManager {

    private static List<Card> cards = new ArrayList<>();

    private static HashMap<Integer,String> baseCard = new HashMap<>();

    public CardManager() {
        CardManager.baseCard.put(3,"3");
        CardManager.baseCard.put(4,"4");
        CardManager.baseCard.put(5,"5");
        CardManager.baseCard.put(6,"6");
        CardManager.baseCard.put(7,"7");
        CardManager.baseCard.put(8,"8");
        CardManager.baseCard.put(9,"9");
        CardManager.baseCard.put(10,"10");
        CardManager.baseCard.put(11,"J");
        CardManager.baseCard.put(12,"Q");
        CardManager.baseCard.put(13,"K");
        CardManager.baseCard.put(14,"A");
        CardManager.baseCard.put(15,"2");

        for (int i=3;i<16;i++){
            Card c1 = new Card(Style.Red,CardManager.baseCard.get(i));
            Card c2 = new Card(Style.Black,CardManager.baseCard.get(i));
            Card c3 = new Card(Style.Block,CardManager.baseCard.get(i));
            Card c4 = new Card(Style.Enum,CardManager.baseCard.get(i));

            CardManager.cards.add(c1);
            CardManager.cards.add(c2);
            CardManager.cards.add(c3);
            CardManager.cards.add(c4);
        }

        Card NumOne = new Card(Style.NumOne,"大王");
        Card NumTwo = new Card(Style.NumTwo,"小王");

        CardManager.cards.add(NumOne);
        CardManager.cards.add(NumTwo);
    }
    //洗牌
    public void Mixed(){
        Collections.shuffle(CardManager.cards);
    }
    //摸牌
    public Card Get(){
        Card card = CardManager.cards.get(CardManager.cards.size() - 1);
        CardManager.cards.remove(card);
        return card;
    }
    //查看底牌
    public void Show(){
        for (Card card : CardManager.cards){
            System.out.println(card);
        }
    }
}
